<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <title>b.html</title>
</head>

<body>
    <p>b页面</p>
    <script type="text/javascript">
        window.onmessage = function (e) {
            //得到父页面的消息
            document.write(e.data)
            //给父页面发送消息
            e.source.postMessage('b.html页面内容', e.origin)
        }
    </script>
</body>

</html>